package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.RevenueModel;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.RevenueModelType;
import com.genexususa.eo.bing.data.GxItemException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class GxRevenueModel extends RevenueModel {
    public GxRevenueModel(Element element) throws IllegalArgumentException, GxItemException {
        if (element.getElementsByTagName("ConstantRevenueValue").getLength() > 0 &&
            element.getElementsByTagName("ConstantRevenueValue").item(0).getChildNodes().getLength() > 0 &&
            Double.valueOf(((Node)element.getElementsByTagName("ConstantRevenueValue").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.setConstantRevenueValue(Double.valueOf(((Node) element.getElementsByTagName("ConstantRevenueValue").item(0).getChildNodes().item(0)).getNodeValue()));
        }
        if (element.getElementsByTagName("Type").getLength() > 0 &&
            element.getElementsByTagName("Type").item(0).getChildNodes().getLength() > 0) {
            this.setType(RevenueModelType.fromString(((Node) element.getElementsByTagName("Type").item(0).getChildNodes().item(0)).getNodeValue()));
        }
    }
}
